Statistical EDA Modeling So Far

Initial Analysis

Here we wanted to show the number of games being played by players to quickly discuss this. We thought going with a 20 game minimum was the best idea for analysis.

PCA

We did Principal Component Analysis to show if any variables stand out more than others.

We wanted to show with elbow plot that not many components were really needed. Note we took out the “Entry Level Contract” type and filtered that players must have played 20 games

We then wanted to see in the first two components what variables had the most weight as this could help us in our reduction methods.

Lasso/Ridge Regression

We wanted to show what the ridge plot looks like.

Also wanted to show the lasso plot.

Next, we wanted to show how all the models compared. We took the linear regression model and compared it to ridge (which has an alpha level of 0) and increased the alpha by every quartile until it got up to 1 (which is a lasso model). Here we wanted to show which model was the best.

## 370 x 1 sparse Matrix of class "dgCMatrix"
##                                                             s0
## (Intercept)                                      -2.745454e+06
## position                                          .           
## team                                              .           
## age                                               1.406116e+05
## x                                                 .           
## ix_g60                                            .           
## i_sh60                                            .           
## i_cf60                                            .           
## sf_percent                                        .           
## cf_percent                                        .           
## x_gf_percent                                      .           
## type                                              2.791848e+05
## expiry                                            .           
## shoots_catches                                   -8.631687e+04
## skater_stats_power_play_goals                     .           
## skater_stats_power_play_assists                   1.539955e+04
## skater_stats_short_handed_goals                   .           
## skater_stats_short_handed_assists                 .           
## games_played                                      .           
## diff_other_x_goals_percentage                     .           
## diff_other_corsi_percentage                       4.645325e+04
## diff_all_x_goals_percentage                       1.112594e+06
## diff_all_corsi_percentage                         6.783054e+05
## diff_5on5_x_goals_percentage                      .           
## diff_5on5_corsi_percentage                        .           
## diff_4on5_x_goals_percentage                      .           
## diff_4on5_corsi_percentage                        .           
## diff_5on4_x_goals_percentage                      .           
## diff_5on4_corsi_percentage                        .           
## diff_other_x_on_goal                              .           
## diff_other_x_goals                                .           
## diff_other_shots_on_goal                          .           
## diff_other_missed_shots                           .           
## diff_other_blocked_shot_attempts                  .           
## diff_other_shot_attempts                          .           
## diff_other_goals                                  .           
## diff_other_rebounds                               .           
## diff_other_rebound_goals                          4.179019e+03
## diff_other_low_danger_shots                       .           
## diff_other_medium_danger_shots                    .           
## diff_other_high_danger_shots                      1.076063e+04
## diff_other_low_dangerx_goals                      .           
## diff_other_medium_dangerx_goals                   .           
## diff_other_high_dangerx_goals                     .           
## diff_other_low_danger_goals                       .           
## diff_other_medium_danger_goals                    .           
## diff_other_high_danger_goals                      .           
## diff_other_unblocked_shot_attempts                .           
## diff_other_x_goals_fromx_rebounds_of_shots        .           
## diff_other_x_goals_from_actual_rebounds_of_shots  .           
## diff_other_reboundx_goals                         .           
## diff_other_x_goals_with_earned_rebounds           .           
## diff_all_x_on_goal                                .           
## diff_all_x_goals                                  .           
## diff_all_shots_on_goal                            .           
## diff_all_missed_shots                             .           
## diff_all_blocked_shot_attempts                    .           
## diff_all_shot_attempts                            .           
## diff_all_goals                                    .           
## diff_all_rebounds                                 .           
## diff_all_rebound_goals                            .           
## diff_all_low_danger_shots                         .           
## diff_all_medium_danger_shots                      .           
## diff_all_high_danger_shots                        8.235260e+02
## diff_all_low_dangerx_goals                        .           
## diff_all_medium_dangerx_goals                     .           
## diff_all_high_dangerx_goals                       .           
## diff_all_low_danger_goals                         .           
## diff_all_medium_danger_goals                      8.208383e+02
## diff_all_high_danger_goals                        .           
## diff_all_unblocked_shot_attempts                  .           
## diff_all_x_goals_fromx_rebounds_of_shots          .           
## diff_all_x_goals_from_actual_rebounds_of_shots    .           
## diff_all_reboundx_goals                           .           
## diff_all_x_goals_with_earned_rebounds             .           
## diff_5on5_x_on_goal                               .           
## diff_5on5_x_goals                                 .           
## diff_5on5_shots_on_goal                           .           
## diff_5on5_missed_shots                            .           
## diff_5on5_blocked_shot_attempts                   .           
## diff_5on5_shot_attempts                           .           
## diff_5on5_goals                                   .           
## diff_5on5_rebounds                                .           
## diff_5on5_rebound_goals                          -1.610453e+04
## diff_5on5_low_danger_shots                        .           
## diff_5on5_medium_danger_shots                     .           
## diff_5on5_high_danger_shots                       .           
## diff_5on5_low_dangerx_goals                       .           
## diff_5on5_medium_dangerx_goals                    .           
## diff_5on5_high_dangerx_goals                      .           
## diff_5on5_low_danger_goals                       -4.600502e+03
## diff_5on5_medium_danger_goals                     .           
## diff_5on5_high_danger_goals                       .           
## diff_5on5_unblocked_shot_attempts                 .           
## diff_5on5_x_goals_fromx_rebounds_of_shots         .           
## diff_5on5_x_goals_from_actual_rebounds_of_shots   .           
## diff_5on5_reboundx_goals                          .           
## diff_5on5_x_goals_with_earned_rebounds            .           
## diff_4on5_x_on_goal                               .           
## diff_4on5_x_goals                                 .           
## diff_4on5_shots_on_goal                           .           
## diff_4on5_missed_shots                            .           
## diff_4on5_blocked_shot_attempts                   .           
## diff_4on5_shot_attempts                           .           
## diff_4on5_goals                                   .           
## diff_4on5_rebounds                                .           
## diff_4on5_rebound_goals                           .           
## diff_4on5_low_danger_shots                        .           
## diff_4on5_medium_danger_shots                     .           
## diff_4on5_high_danger_shots                       .           
## diff_4on5_low_dangerx_goals                       .           
## diff_4on5_medium_dangerx_goals                    .           
## diff_4on5_high_dangerx_goals                      .           
## diff_4on5_low_danger_goals                        .           
## diff_4on5_medium_danger_goals                     .           
## diff_4on5_high_danger_goals                       .           
## diff_4on5_unblocked_shot_attempts                 .           
## diff_4on5_x_goals_fromx_rebounds_of_shots         .           
## diff_4on5_x_goals_from_actual_rebounds_of_shots   .           
## diff_4on5_reboundx_goals                          .           
## diff_4on5_x_goals_with_earned_rebounds            .           
## diff_5on4_x_on_goal                               .           
## diff_5on4_x_goals                                 .           
## diff_5on4_shots_on_goal                           .           
## diff_5on4_missed_shots                            .           
## diff_5on4_blocked_shot_attempts                   .           
## diff_5on4_shot_attempts                           .           
## diff_5on4_goals                                   .           
## diff_5on4_rebounds                                .           
## diff_5on4_rebound_goals                           3.977725e+04
## diff_5on4_low_danger_shots                        .           
## diff_5on4_medium_danger_shots                     .           
## diff_5on4_high_danger_shots                       .           
## diff_5on4_low_dangerx_goals                       .           
## diff_5on4_medium_dangerx_goals                    .           
## diff_5on4_high_dangerx_goals                      .           
## diff_5on4_low_danger_goals                        .           
## diff_5on4_medium_danger_goals                     .           
## diff_5on4_high_danger_goals                       .           
## diff_5on4_unblocked_shot_attempts                 .           
## diff_5on4_x_goals_fromx_rebounds_of_shots         8.106352e+04
## diff_5on4_x_goals_from_actual_rebounds_of_shots   1.484678e+04
## diff_5on4_reboundx_goals                          3.403994e+04
## diff_5on4_x_goals_with_earned_rebounds            .           
## other_icetime                                     .           
## all_icetime                                       .           
## x5on5_icetime                                     .           
## x4on5_icetime                                     .           
## x5on4_icetime                                     .           
## other_i_f_x_on_goal                               .           
## all_i_f_x_on_goal                                 .           
## x5on5_i_f_x_on_goal                               .           
## x4on5_i_f_x_on_goal                               .           
## x5on4_i_f_x_on_goal                               .           
## other_i_f_x_goals                                 .           
## all_i_f_x_goals                                   .           
## x5on5_i_f_x_goals                                 .           
## x4on5_i_f_x_goals                                 .           
## x5on4_i_f_x_goals                                 .           
## other_i_f_x_rebounds                              2.388166e+04
## all_i_f_x_rebounds                                .           
## x5on5_i_f_x_rebounds                              .           
## x4on5_i_f_x_rebounds                              .           
## x5on4_i_f_x_rebounds                              .           
## other_i_f_x_play_continued_in_zone                .           
## all_i_f_x_play_continued_in_zone                  .           
## x5on5_i_f_x_play_continued_in_zone                .           
## x4on5_i_f_x_play_continued_in_zone                .           
## x5on4_i_f_x_play_continued_in_zone                .           
## other_i_f_x_play_continued_outside_zone           .           
## all_i_f_x_play_continued_outside_zone             .           
## x5on5_i_f_x_play_continued_outside_zone           .           
## x4on5_i_f_x_play_continued_outside_zone           .           
## x5on4_i_f_x_play_continued_outside_zone           .           
## other_i_f_primary_assists                         .           
## all_i_f_primary_assists                           8.250216e+03
## x5on5_i_f_primary_assists                         .           
## x4on5_i_f_primary_assists                         .           
## x5on4_i_f_primary_assists                         .           
## other_i_f_secondary_assists                       .           
## all_i_f_secondary_assists                         1.615344e+04
## x5on5_i_f_secondary_assists                       .           
## x4on5_i_f_secondary_assists                      -1.280227e+05
## x5on4_i_f_secondary_assists                       .           
## other_i_f_shots_on_goal                           .           
## all_i_f_shots_on_goal                             .           
## x5on5_i_f_shots_on_goal                           .           
## x4on5_i_f_shots_on_goal                           .           
## x5on4_i_f_shots_on_goal                           .           
## other_i_f_missed_shots                            .           
## all_i_f_missed_shots                              .           
## x5on5_i_f_missed_shots                            .           
## x4on5_i_f_missed_shots                            .           
## x5on4_i_f_missed_shots                            .           
## other_i_f_blocked_shot_attempts                   .           
## all_i_f_blocked_shot_attempts                     .           
## x5on5_i_f_blocked_shot_attempts                   .           
## x4on5_i_f_blocked_shot_attempts                  -1.586253e+04
## x5on4_i_f_blocked_shot_attempts                   .           
## other_i_f_shot_attempts                           .           
## all_i_f_shot_attempts                             .           
## x5on5_i_f_shot_attempts                           .           
## x4on5_i_f_shot_attempts                           .           
## x5on4_i_f_shot_attempts                           .           
## other_i_f_points                                  .           
## all_i_f_points                                    .           
## x5on5_i_f_points                                  .           
## x4on5_i_f_points                                  .           
## x5on4_i_f_points                                  .           
## other_i_f_goals                                   .           
## all_i_f_goals                                     .           
## x5on5_i_f_goals                                   .           
## x4on5_i_f_goals                                   .           
## x5on4_i_f_goals                                   .           
## other_i_f_rebounds                                .           
## all_i_f_rebounds                                  .           
## x5on5_i_f_rebounds                                .           
## x4on5_i_f_rebounds                                .           
## x5on4_i_f_rebounds                                .           
## other_i_f_rebound_goals                           .           
## all_i_f_rebound_goals                             .           
## x5on5_i_f_rebound_goals                           .           
## x4on5_i_f_rebound_goals                           .           
## x5on4_i_f_rebound_goals                           .           
## other_i_f_play_continued_in_zone                  .           
## all_i_f_play_continued_in_zone                    .           
## x5on5_i_f_play_continued_in_zone                  .           
## x4on5_i_f_play_continued_in_zone                  .           
## x5on4_i_f_play_continued_in_zone                  5.671506e+04
## other_i_f_play_continued_outside_zone             3.676679e+04
## all_i_f_play_continued_outside_zone               .           
## x5on5_i_f_play_continued_outside_zone             .           
## x4on5_i_f_play_continued_outside_zone             .           
## x5on4_i_f_play_continued_outside_zone             .           
## other_i_f_saved_shots_on_goal                     .           
## all_i_f_saved_shots_on_goal                       .           
## x5on5_i_f_saved_shots_on_goal                     .           
## x4on5_i_f_saved_shots_on_goal                     .           
## x5on4_i_f_saved_shots_on_goal                     .           
## other_i_f_hits                                    2.609656e+03
## all_i_f_hits                                      .           
## x5on5_i_f_hits                                    .           
## x4on5_i_f_hits                                    .           
## x5on4_i_f_hits                                    .           
## other_i_f_takeaways                               6.799045e+04
## all_i_f_takeaways                                 .           
## x5on5_i_f_takeaways                               1.546996e+04
## x4on5_i_f_takeaways                               .           
## x5on4_i_f_takeaways                               .           
## other_i_f_giveaways                               .           
## all_i_f_giveaways                                 2.992792e+03
## x5on5_i_f_giveaways                               7.304789e+03
## x4on5_i_f_giveaways                               .           
## x5on4_i_f_giveaways                               .           
## other_i_f_low_danger_shots                        .           
## all_i_f_low_danger_shots                          .           
## x5on5_i_f_low_danger_shots                        .           
## x4on5_i_f_low_danger_shots                        .           
## x5on4_i_f_low_danger_shots                        .           
## other_i_f_medium_danger_shots                     .           
## all_i_f_medium_danger_shots                       .           
## x5on5_i_f_medium_danger_shots                     .           
## x4on5_i_f_medium_danger_shots                     .           
## x5on4_i_f_medium_danger_shots                     .           
## other_i_f_high_danger_shots                       .           
## all_i_f_high_danger_shots                         .           
## x5on5_i_f_high_danger_shots                       .           
## x4on5_i_f_high_danger_shots                      -1.968148e+04
## x5on4_i_f_high_danger_shots                       .           
## other_i_f_low_dangerx_goals                       .           
## all_i_f_low_dangerx_goals                         .           
## x5on5_i_f_low_dangerx_goals                       .           
## x4on5_i_f_low_dangerx_goals                       .           
## x5on4_i_f_low_dangerx_goals                       .           
## other_i_f_medium_dangerx_goals                    .           
## all_i_f_medium_dangerx_goals                      .           
## x5on5_i_f_medium_dangerx_goals                    .           
## x4on5_i_f_medium_dangerx_goals                    .           
## x5on4_i_f_medium_dangerx_goals                    .           
## other_i_f_high_dangerx_goals                      .           
## all_i_f_high_dangerx_goals                        .           
## x5on5_i_f_high_dangerx_goals                      .           
## x4on5_i_f_high_dangerx_goals                      .           
## x5on4_i_f_high_dangerx_goals                      .           
## other_i_f_low_danger_goals                        .           
## all_i_f_low_danger_goals                          .           
## x5on5_i_f_low_danger_goals                        .           
## x4on5_i_f_low_danger_goals                       -3.318223e+05
## x5on4_i_f_low_danger_goals                        .           
## other_i_f_medium_danger_goals                     .           
## all_i_f_medium_danger_goals                       .           
## x5on5_i_f_medium_danger_goals                     .           
## x4on5_i_f_medium_danger_goals                    -1.499102e+04
## x5on4_i_f_medium_danger_goals                     .           
## other_i_f_high_danger_goals                       .           
## all_i_f_high_danger_goals                         .           
## x5on5_i_f_high_danger_goals                       .           
## x4on5_i_f_high_danger_goals                       .           
## x5on4_i_f_high_danger_goals                       .           
## other_i_f_unblocked_shot_attempts                 .           
## all_i_f_unblocked_shot_attempts                   .           
## x5on5_i_f_unblocked_shot_attempts                 .           
## x4on5_i_f_unblocked_shot_attempts                 .           
## x5on4_i_f_unblocked_shot_attempts                 .           
## other_i_f_d_zone_giveaways                        7.575754e+04
## all_i_f_d_zone_giveaways                          .           
## x5on5_i_f_d_zone_giveaways                        .           
## x4on5_i_f_d_zone_giveaways                        .           
## x5on4_i_f_d_zone_giveaways                        .           
## other_i_f_x_goals_fromx_rebounds_of_shots         4.330224e+04
## all_i_f_x_goals_fromx_rebounds_of_shots           .           
## x5on5_i_f_x_goals_fromx_rebounds_of_shots         .           
## x4on5_i_f_x_goals_fromx_rebounds_of_shots         .           
## x5on4_i_f_x_goals_fromx_rebounds_of_shots         .           
## other_i_f_x_goals_from_actual_rebounds_of_shots   .           
## all_i_f_x_goals_from_actual_rebounds_of_shots     .           
## x5on5_i_f_x_goals_from_actual_rebounds_of_shots   .           
## x4on5_i_f_x_goals_from_actual_rebounds_of_shots   .           
## x5on4_i_f_x_goals_from_actual_rebounds_of_shots   .           
## other_i_f_reboundx_goals                          .           
## all_i_f_reboundx_goals                            .           
## x5on5_i_f_reboundx_goals                          .           
## x4on5_i_f_reboundx_goals                         -8.308048e+04
## x5on4_i_f_reboundx_goals                          .           
## other_i_f_o_zone_shift_ends                       .           
## all_i_f_o_zone_shift_ends                         .           
## x5on5_i_f_o_zone_shift_ends                       .           
## x4on5_i_f_o_zone_shift_ends                       .           
## x5on4_i_f_o_zone_shift_ends                       .           
## other_i_f_d_zone_shift_ends                       .           
## all_i_f_d_zone_shift_ends                         .           
## x5on5_i_f_d_zone_shift_ends                       .           
## x4on5_i_f_d_zone_shift_ends                       .           
## x5on4_i_f_d_zone_shift_ends                       .           
## other_i_f_neutral_zone_shift_ends                 4.345798e+04
## all_i_f_neutral_zone_shift_ends                   .           
## x5on5_i_f_neutral_zone_shift_ends                 .           
## x4on5_i_f_neutral_zone_shift_ends                 .           
## x5on4_i_f_neutral_zone_shift_ends                 .           
## other_faceoffs_won                                .           
## all_faceoffs_won                                  .           
## x5on5_faceoffs_won                                .           
## x4on5_faceoffs_won                                .           
## x5on4_faceoffs_won                                2.215846e+03
## other_faceoffs_lost                               .           
## all_faceoffs_lost                                 .           
## x5on5_faceoffs_lost                               .           
## x4on5_faceoffs_lost                               .           
## x5on4_faceoffs_lost                               .           
## other_time_on_bench                               .           
## all_time_on_bench                                -5.327350e+00
## x5on5_time_on_bench                               .           
## x4on5_time_on_bench                               .           
## x5on4_time_on_bench                               .           
## other_shots_blocked_by_player                     .           
## all_shots_blocked_by_player                       .           
## x5on5_shots_blocked_by_player                     .           
## x4on5_shots_blocked_by_player                    -5.215833e+04
## x5on4_shots_blocked_by_player                     .           
## other_diff_number_of_penalty                      .           
## all_diff_number_of_penalty                        .           
## x5on5_diff_number_of_penalty                      .           
## x4on5_diff_number_of_penalty                      3.223018e+03
## x5on4_diff_number_of_penalty                      .           
## other_diff_penalty_minutes                        .           
## all_diff_penalty_minutes                          .           
## x5on5_diff_penalty_minutes                        .           
## x4on5_diff_penalty_minutes                        .           
## x5on4_diff_penalty_minutes                        .           
## test_fold                                         .
## 370 x 1 sparse Matrix of class "dgCMatrix"
##                                                             s0
## (Intercept)                                      -2.267918e+06
## position                                          .           
## team                                              6.885255e+03
## age                                               1.121365e+05
## x                                                 .           
## ix_g60                                            .           
## i_sh60                                            .           
## i_cf60                                            .           
## sf_percent                                        .           
## cf_percent                                        .           
## x_gf_percent                                      .           
## type                                              2.620432e+05
## expiry                                            8.224642e+04
## shoots_catches                                    .           
## skater_stats_power_play_goals                     .           
## skater_stats_power_play_assists                   .           
## skater_stats_short_handed_goals                   .           
## skater_stats_short_handed_assists                 .           
## games_played                                      .           
## diff_other_x_goals_percentage                     .           
## diff_other_corsi_percentage                       .           
## diff_all_x_goals_percentage                       .           
## diff_all_corsi_percentage                         .           
## diff_5on5_x_goals_percentage                      .           
## diff_5on5_corsi_percentage                        3.892032e+06
## diff_4on5_x_goals_percentage                      .           
## diff_4on5_corsi_percentage                        .           
## diff_5on4_x_goals_percentage                      .           
## diff_5on4_corsi_percentage                        .           
## diff_other_x_on_goal                              .           
## diff_other_x_goals                                .           
## diff_other_shots_on_goal                          .           
## diff_other_missed_shots                          -4.915081e+03
## diff_other_blocked_shot_attempts                  .           
## diff_other_shot_attempts                          .           
## diff_other_goals                                  .           
## diff_other_rebounds                               .           
## diff_other_rebound_goals                          .           
## diff_other_low_danger_shots                       .           
## diff_other_medium_danger_shots                    .           
## diff_other_high_danger_shots                      .           
## diff_other_low_dangerx_goals                      .           
## diff_other_medium_dangerx_goals                   .           
## diff_other_high_dangerx_goals                     .           
## diff_other_low_danger_goals                      -1.423014e+05
## diff_other_medium_danger_goals                   -1.590961e+04
## diff_other_high_danger_goals                      .           
## diff_other_unblocked_shot_attempts                .           
## diff_other_x_goals_fromx_rebounds_of_shots        .           
## diff_other_x_goals_from_actual_rebounds_of_shots  .           
## diff_other_reboundx_goals                         .           
## diff_other_x_goals_with_earned_rebounds           .           
## diff_all_x_on_goal                                .           
## diff_all_x_goals                                  .           
## diff_all_shots_on_goal                            .           
## diff_all_missed_shots                             .           
## diff_all_blocked_shot_attempts                    .           
## diff_all_shot_attempts                            .           
## diff_all_goals                                    .           
## diff_all_rebounds                                 .           
## diff_all_rebound_goals                            .           
## diff_all_low_danger_shots                         .           
## diff_all_medium_danger_shots                      .           
## diff_all_high_danger_shots                        .           
## diff_all_low_dangerx_goals                        .           
## diff_all_medium_dangerx_goals                     .           
## diff_all_high_dangerx_goals                       .           
## diff_all_low_danger_goals                         .           
## diff_all_medium_danger_goals                      .           
## diff_all_high_danger_goals                        .           
## diff_all_unblocked_shot_attempts                  .           
## diff_all_x_goals_fromx_rebounds_of_shots          .           
## diff_all_x_goals_from_actual_rebounds_of_shots    .           
## diff_all_reboundx_goals                           .           
## diff_all_x_goals_with_earned_rebounds             .           
## diff_5on5_x_on_goal                               .           
## diff_5on5_x_goals                                 .           
## diff_5on5_shots_on_goal                           .           
## diff_5on5_missed_shots                            .           
## diff_5on5_blocked_shot_attempts                   .           
## diff_5on5_shot_attempts                           .           
## diff_5on5_goals                                   .           
## diff_5on5_rebounds                                .           
## diff_5on5_rebound_goals                          -9.478278e+01
## diff_5on5_low_danger_shots                        .           
## diff_5on5_medium_danger_shots                     .           
## diff_5on5_high_danger_shots                       .           
## diff_5on5_low_dangerx_goals                       .           
## diff_5on5_medium_dangerx_goals                    .           
## diff_5on5_high_dangerx_goals                      .           
## diff_5on5_low_danger_goals                        1.365129e+04
## diff_5on5_medium_danger_goals                     .           
## diff_5on5_high_danger_goals                       .           
## diff_5on5_unblocked_shot_attempts                 .           
## diff_5on5_x_goals_fromx_rebounds_of_shots         .           
## diff_5on5_x_goals_from_actual_rebounds_of_shots   .           
## diff_5on5_reboundx_goals                          .           
## diff_5on5_x_goals_with_earned_rebounds            .           
## diff_4on5_x_on_goal                               .           
## diff_4on5_x_goals                                 .           
## diff_4on5_shots_on_goal                           .           
## diff_4on5_missed_shots                            .           
## diff_4on5_blocked_shot_attempts                   .           
## diff_4on5_shot_attempts                           .           
## diff_4on5_goals                                   .           
## diff_4on5_rebounds                                .           
## diff_4on5_rebound_goals                           .           
## diff_4on5_low_danger_shots                        .           
## diff_4on5_medium_danger_shots                     .           
## diff_4on5_high_danger_shots                       .           
## diff_4on5_low_dangerx_goals                       .           
## diff_4on5_medium_dangerx_goals                    .           
## diff_4on5_high_dangerx_goals                      .           
## diff_4on5_low_danger_goals                        .           
## diff_4on5_medium_danger_goals                     .           
## diff_4on5_high_danger_goals                       .           
## diff_4on5_unblocked_shot_attempts                 .           
## diff_4on5_x_goals_fromx_rebounds_of_shots         .           
## diff_4on5_x_goals_from_actual_rebounds_of_shots   .           
## diff_4on5_reboundx_goals                          .           
## diff_4on5_x_goals_with_earned_rebounds            .           
## diff_5on4_x_on_goal                               .           
## diff_5on4_x_goals                                 .           
## diff_5on4_shots_on_goal                           .           
## diff_5on4_missed_shots                            4.687439e+02
## diff_5on4_blocked_shot_attempts                   4.044663e+02
## diff_5on4_shot_attempts                           .           
## diff_5on4_goals                                   .           
## diff_5on4_rebounds                                3.144132e+02
## diff_5on4_rebound_goals                           .           
## diff_5on4_low_danger_shots                        .           
## diff_5on4_medium_danger_shots                     .           
## diff_5on4_high_danger_shots                       .           
## diff_5on4_low_dangerx_goals                       .           
## diff_5on4_medium_dangerx_goals                    .           
## diff_5on4_high_dangerx_goals                      .           
## diff_5on4_low_danger_goals                        4.544523e+04
## diff_5on4_medium_danger_goals                     .           
## diff_5on4_high_danger_goals                       .           
## diff_5on4_unblocked_shot_attempts                 .           
## diff_5on4_x_goals_fromx_rebounds_of_shots         .           
## diff_5on4_x_goals_from_actual_rebounds_of_shots   .           
## diff_5on4_reboundx_goals                          .           
## diff_5on4_x_goals_with_earned_rebounds            .           
## other_icetime                                     3.243593e+02
## all_icetime                                       .           
## x5on5_icetime                                     .           
## x4on5_icetime                                     .           
## x5on4_icetime                                     .           
## other_i_f_x_on_goal                               .           
## all_i_f_x_on_goal                                 .           
## x5on5_i_f_x_on_goal                               .           
## x4on5_i_f_x_on_goal                               .           
## x5on4_i_f_x_on_goal                               .           
## other_i_f_x_goals                                 .           
## all_i_f_x_goals                                   .           
## x5on5_i_f_x_goals                                 .           
## x4on5_i_f_x_goals                                 .           
## x5on4_i_f_x_goals                                 .           
## other_i_f_x_rebounds                              .           
## all_i_f_x_rebounds                                .           
## x5on5_i_f_x_rebounds                              .           
## x4on5_i_f_x_rebounds                              .           
## x5on4_i_f_x_rebounds                              .           
## other_i_f_x_play_continued_in_zone                .           
## all_i_f_x_play_continued_in_zone                  .           
## x5on5_i_f_x_play_continued_in_zone                .           
## x4on5_i_f_x_play_continued_in_zone                .           
## x5on4_i_f_x_play_continued_in_zone                .           
## other_i_f_x_play_continued_outside_zone           .           
## all_i_f_x_play_continued_outside_zone             .           
## x5on5_i_f_x_play_continued_outside_zone           .           
## x4on5_i_f_x_play_continued_outside_zone           .           
## x5on4_i_f_x_play_continued_outside_zone           .           
## other_i_f_primary_assists                         .           
## all_i_f_primary_assists                           .           
## x5on5_i_f_primary_assists                         .           
## x4on5_i_f_primary_assists                         .           
## x5on4_i_f_primary_assists                         .           
## other_i_f_secondary_assists                       .           
## all_i_f_secondary_assists                         .           
## x5on5_i_f_secondary_assists                       .           
## x4on5_i_f_secondary_assists                       .           
## x5on4_i_f_secondary_assists                       .           
## other_i_f_shots_on_goal                           .           
## all_i_f_shots_on_goal                             .           
## x5on5_i_f_shots_on_goal                           .           
## x4on5_i_f_shots_on_goal                           .           
## x5on4_i_f_shots_on_goal                           .           
## other_i_f_missed_shots                            .           
## all_i_f_missed_shots                              .           
## x5on5_i_f_missed_shots                            .           
## x4on5_i_f_missed_shots                            .           
## x5on4_i_f_missed_shots                            .           
## other_i_f_blocked_shot_attempts                   2.357443e+04
## all_i_f_blocked_shot_attempts                     .           
## x5on5_i_f_blocked_shot_attempts                   .           
## x4on5_i_f_blocked_shot_attempts                   .           
## x5on4_i_f_blocked_shot_attempts                   7.309181e+03
## other_i_f_shot_attempts                           .           
## all_i_f_shot_attempts                             .           
## x5on5_i_f_shot_attempts                           .           
## x4on5_i_f_shot_attempts                           .           
## x5on4_i_f_shot_attempts                           .           
## other_i_f_points                                  .           
## all_i_f_points                                    .           
## x5on5_i_f_points                                  .           
## x4on5_i_f_points                                  .           
## x5on4_i_f_points                                  .           
## other_i_f_goals                                   .           
## all_i_f_goals                                     .           
## x5on5_i_f_goals                                   .           
## x4on5_i_f_goals                                   .           
## x5on4_i_f_goals                                   .           
## other_i_f_rebounds                                .           
## all_i_f_rebounds                                  .           
## x5on5_i_f_rebounds                                .           
## x4on5_i_f_rebounds                                .           
## x5on4_i_f_rebounds                                .           
## other_i_f_rebound_goals                           .           
## all_i_f_rebound_goals                             .           
## x5on5_i_f_rebound_goals                           .           
## x4on5_i_f_rebound_goals                           .           
## x5on4_i_f_rebound_goals                           .           
## other_i_f_play_continued_in_zone                  .           
## all_i_f_play_continued_in_zone                    .           
## x5on5_i_f_play_continued_in_zone                  .           
## x4on5_i_f_play_continued_in_zone                  .           
## x5on4_i_f_play_continued_in_zone                  .           
## other_i_f_play_continued_outside_zone             .           
## all_i_f_play_continued_outside_zone               1.633282e+04
## x5on5_i_f_play_continued_outside_zone             .           
## x4on5_i_f_play_continued_outside_zone             7.579989e+03
## x5on4_i_f_play_continued_outside_zone             .           
## other_i_f_saved_shots_on_goal                     .           
## all_i_f_saved_shots_on_goal                       .           
## x5on5_i_f_saved_shots_on_goal                     .           
## x4on5_i_f_saved_shots_on_goal                     .           
## x5on4_i_f_saved_shots_on_goal                     .           
## other_i_f_hits                                    .           
## all_i_f_hits                                      .           
## x5on5_i_f_hits                                    .           
## x4on5_i_f_hits                                    .           
## x5on4_i_f_hits                                    .           
## other_i_f_takeaways                               .           
## all_i_f_takeaways                                 .           
## x5on5_i_f_takeaways                               .           
## x4on5_i_f_takeaways                               .           
## x5on4_i_f_takeaways                               .           
## other_i_f_giveaways                               2.186179e+04
## all_i_f_giveaways                                 .           
## x5on5_i_f_giveaways                               .           
## x4on5_i_f_giveaways                               .           
## x5on4_i_f_giveaways                               .           
## other_i_f_low_danger_shots                        .           
## all_i_f_low_danger_shots                          .           
## x5on5_i_f_low_danger_shots                        .           
## x4on5_i_f_low_danger_shots                        .           
## x5on4_i_f_low_danger_shots                        .           
## other_i_f_medium_danger_shots                     .           
## all_i_f_medium_danger_shots                       2.315194e+03
## x5on5_i_f_medium_danger_shots                     .           
## x4on5_i_f_medium_danger_shots                     .           
## x5on4_i_f_medium_danger_shots                     .           
## other_i_f_high_danger_shots                       .           
## all_i_f_high_danger_shots                         .           
## x5on5_i_f_high_danger_shots                       .           
## x4on5_i_f_high_danger_shots                       .           
## x5on4_i_f_high_danger_shots                       .           
## other_i_f_low_dangerx_goals                       .           
## all_i_f_low_dangerx_goals                         .           
## x5on5_i_f_low_dangerx_goals                       .           
## x4on5_i_f_low_dangerx_goals                       .           
## x5on4_i_f_low_dangerx_goals                       .           
## other_i_f_medium_dangerx_goals                    .           
## all_i_f_medium_dangerx_goals                      4.220355e+05
## x5on5_i_f_medium_dangerx_goals                    .           
## x4on5_i_f_medium_dangerx_goals                    .           
## x5on4_i_f_medium_dangerx_goals                    .           
## other_i_f_high_dangerx_goals                      .           
## all_i_f_high_dangerx_goals                        .           
## x5on5_i_f_high_dangerx_goals                      .           
## x4on5_i_f_high_dangerx_goals                      .           
## x5on4_i_f_high_dangerx_goals                      .           
## other_i_f_low_danger_goals                        .           
## all_i_f_low_danger_goals                          .           
## x5on5_i_f_low_danger_goals                        .           
## x4on5_i_f_low_danger_goals                        .           
## x5on4_i_f_low_danger_goals                        .           
## other_i_f_medium_danger_goals                     .           
## all_i_f_medium_danger_goals                       .           
## x5on5_i_f_medium_danger_goals                     .           
## x4on5_i_f_medium_danger_goals                    -5.817501e+05
## x5on4_i_f_medium_danger_goals                     .           
## other_i_f_high_danger_goals                       .           
## all_i_f_high_danger_goals                         .           
## x5on5_i_f_high_danger_goals                       .           
## x4on5_i_f_high_danger_goals                       .           
## x5on4_i_f_high_danger_goals                       .           
## other_i_f_unblocked_shot_attempts                 .           
## all_i_f_unblocked_shot_attempts                   .           
## x5on5_i_f_unblocked_shot_attempts                 .           
## x4on5_i_f_unblocked_shot_attempts                 .           
## x5on4_i_f_unblocked_shot_attempts                 .           
## other_i_f_d_zone_giveaways                        .           
## all_i_f_d_zone_giveaways                          .           
## x5on5_i_f_d_zone_giveaways                        .           
## x4on5_i_f_d_zone_giveaways                        .           
## x5on4_i_f_d_zone_giveaways                        .           
## other_i_f_x_goals_fromx_rebounds_of_shots         .           
## all_i_f_x_goals_fromx_rebounds_of_shots           .           
## x5on5_i_f_x_goals_fromx_rebounds_of_shots         .           
## x4on5_i_f_x_goals_fromx_rebounds_of_shots         .           
## x5on4_i_f_x_goals_fromx_rebounds_of_shots         .           
## other_i_f_x_goals_from_actual_rebounds_of_shots   .           
## all_i_f_x_goals_from_actual_rebounds_of_shots     .           
## x5on5_i_f_x_goals_from_actual_rebounds_of_shots   .           
## x4on5_i_f_x_goals_from_actual_rebounds_of_shots   .           
## x5on4_i_f_x_goals_from_actual_rebounds_of_shots   .           
## other_i_f_reboundx_goals                          1.504252e+05
## all_i_f_reboundx_goals                            .           
## x5on5_i_f_reboundx_goals                          .           
## x4on5_i_f_reboundx_goals                          2.761572e+05
## x5on4_i_f_reboundx_goals                          .           
## other_i_f_o_zone_shift_ends                       .           
## all_i_f_o_zone_shift_ends                         .           
## x5on5_i_f_o_zone_shift_ends                       .           
## x4on5_i_f_o_zone_shift_ends                       .           
## x5on4_i_f_o_zone_shift_ends                       .           
## other_i_f_d_zone_shift_ends                       .           
## all_i_f_d_zone_shift_ends                         .           
## x5on5_i_f_d_zone_shift_ends                       .           
## x4on5_i_f_d_zone_shift_ends                       .           
## x5on4_i_f_d_zone_shift_ends                       1.834465e+04
## other_i_f_neutral_zone_shift_ends                 3.054726e+04
## all_i_f_neutral_zone_shift_ends                   .           
## x5on5_i_f_neutral_zone_shift_ends                 .           
## x4on5_i_f_neutral_zone_shift_ends                 .           
## x5on4_i_f_neutral_zone_shift_ends                 .           
## other_faceoffs_won                                .           
## all_faceoffs_won                                  .           
## x5on5_faceoffs_won                                .           
## x4on5_faceoffs_won                                .           
## x5on4_faceoffs_won                                .           
## other_faceoffs_lost                               .           
## all_faceoffs_lost                                 .           
## x5on5_faceoffs_lost                               .           
## x4on5_faceoffs_lost                               .           
## x5on4_faceoffs_lost                               .           
## other_time_on_bench                               .           
## all_time_on_bench                                -8.429820e+00
## x5on5_time_on_bench                               .           
## x4on5_time_on_bench                               .           
## x5on4_time_on_bench                               .           
## other_shots_blocked_by_player                     .           
## all_shots_blocked_by_player                       .           
## x5on5_shots_blocked_by_player                     .           
## x4on5_shots_blocked_by_player                     .           
## x5on4_shots_blocked_by_player                     .           
## other_diff_number_of_penalty                      .           
## all_diff_number_of_penalty                        .           
## x5on5_diff_number_of_penalty                      .           
## x4on5_diff_number_of_penalty                      .           
## x5on4_diff_number_of_penalty                      .           
## other_diff_penalty_minutes                        .           
## all_diff_penalty_minutes                          .           
## x5on5_diff_penalty_minutes                        .           
## x4on5_diff_penalty_minutes                        .           
## x5on4_diff_penalty_minutes                        .           
## test_fold                                         .

Random Forest

Here we wanted to show a plot of the top 100 most important variables in this type of dimension reduction technique.

## Ranger result
## 
## Call:
##  ranger(cap_hit ~ ., salary21Subset, importance = "impurity",      mtry = ncol(salary21Subset)/3) 
## 
## Type:                             Regression 
## Number of trees:                  500 
## Sample size:                      663 
## Number of independent variables:  369 
## Mtry:                             123 
## Target node size:                 5 
## Variable importance mode:         impurity 
## Splitrule:                        variance 
## OOB prediction error (MSE):       2.354971e+12 
## R squared (OOB):                  0.6527016

We did the same thing subsetting the data by forwards.

## Ranger result
## 
## Call:
##  ranger(cap_hit ~ ., salary21SubsetForward, importance = "impurity",      num.trees = 400, mtry = ncol(salary21SubsetForward)/3) 
## 
## Type:                             Regression 
## Number of trees:                  400 
## Sample size:                      447 
## Number of independent variables:  368 
## Mtry:                             123 
## Target node size:                 5 
## Variable importance mode:         impurity 
## Splitrule:                        variance 
## OOB prediction error (MSE):       2.460151e+12 
## R squared (OOB):                  0.6572097

And lastly did the same random forest technique subsetting it by defense.

## Ranger result
## 
## Call:
##  ranger(cap_hit ~ ., salary21SubsetDefense, importance = "impurity",      num.trees = 400, mtry = ncol(salary21SubsetDefense)/3) 
## 
## Type:                             Regression 
## Number of trees:                  400 
## Sample size:                      216 
## Number of independent variables:  368 
## Mtry:                             123 
## Target node size:                 5 
## Variable importance mode:         impurity 
## Splitrule:                        variance 
## OOB prediction error (MSE):       2.597281e+12 
## R squared (OOB):                  0.5661637

Trying to find the most important variables

By having these different plots, we tried to see if we could find a pattern somewhere that would give us the most important variables to use in our reduction.

We first looked at the all data, without subsetting by position.

## # A tibble: 132 × 2
##    value                                     n
##    <chr>                                 <int>
##  1 age                                       2
##  2 all_i_f_primary_assists                   2
##  3 all_i_f_secondary_assists                 2
##  4 all_time_on_bench                         2
##  5 diff_5on4_rebound_goals                   2
##  6 diff_all_high_danger_shots                2
##  7 diff_other_low_danger_goals               2
##  8 expiry                                    2
##  9 other_i_f_neutral_zone_shift_ends         2
## 10 other_i_f_play_continued_outside_zone     2
## # … with 122 more rows

We then did the same doing by forwards.

## # A tibble: 121 × 2
##    value                                               n
##    <chr>                                           <int>
##  1 age                                                 2
##  2 all_i_f_giveaways                                   2
##  3 all_i_f_primary_assists                             2
##  4 all_i_f_secondary_assists                           2
##  5 all_time_on_bench                                   2
##  6 diff_5on4_rebound_goals                             2
##  7 diff_5on4_reboundx_goals                            2
##  8 diff_5on4_x_goals_from_actual_rebounds_of_shots     2
##  9 diff_5on4_x_goals_fromx_rebounds_of_shots           2
## 10 diff_all_high_danger_shots                          2
## # … with 111 more rows

And lastly looked at the defensive players.

## # A tibble: 127 × 2
##    value                                               n
##    <chr>                                           <int>
##  1 age                                                 2
##  2 all_i_f_primary_assists                             2
##  3 all_i_f_secondary_assists                           2
##  4 all_time_on_bench                                   2
##  5 diff_5on4_x_goals_from_actual_rebounds_of_shots     2
##  6 diff_all_corsi_percentage                           2
##  7 diff_other_high_danger_shots                        2
##  8 other_i_f_neutral_zone_shift_ends                   2
##  9 other_i_f_x_goals_fromx_rebounds_of_shots           2
## 10 other_i_f_x_rebounds                                2
## # … with 117 more rows

By using random forest, we could look at what the model says is the optimal number of predictors we should end up using.